﻿using System;
using System.Web.Mvc;

namespace LogikBug.ModularMvc
{
	public static class DependencyResolverExtensions
	{
		public static T GetInstance<T>(this IDependencyResolver resolver)
		{
			var service = resolver.GetService(typeof(T));

			if (service is T)
			{
				return (T) service;
			}

			return default(T);
		}

		public static object GetInstance(this IDependencyResolver resolver, Type serviceType)
		{
			return resolver.GetService(serviceType);
		}
	}
}
